"""

@Time: 2021/9/13 15:17
@Author:
@File: ProvinceService.py
"""
from fastapi import Depends
from dependencies import get_mysql_db
from sqlalchemy.orm import Session
from models.po.mysql_po import Province
from typing import List


class ProvinceService:
    def __init__(self, mysql: Session = Depends(get_mysql_db)):
        self.mysql = mysql

    def __del__(self):
        self.mysql.close()

    def get_provinces(self) -> List[Province]:
        q = self.mysql.query(Province)
        return q.all()
